$(function(){
	var dataTable = $("#bpUserMessageDataTable").DataTable({
		"ajax": {
			"url": '/bpUserMessage/list',
			"data": function(data){
				data.type = $("#type").val();
				data.postId = $("#postId").val();
//				data.commentUserNick = $("#commentUserNick").val();
				data.createTime = $("#createTime").val();
				data.isRead = $("#isRead").val();
			}
		},
		"ordering": false,
		"columns": [
//			{
//				"data": "id",
//				"className": "text-center sign-col",
//				"render": function(data, type, row, meta){
//					return '<input type="checkbox" name="pk" value="' + data + '" onclick="checkOne()"/>';
//				}
//			},
			{"data": "userId"},
//			{"data": "commentUserNick"},
			{"data": "type"},
			{"data": "postId"},
			{"data": "commentUserId"},
			{"data": "content"},
			{
				"data": function(obj){
					return new Date(obj.createTime).Format("yyyy-MM-dd hh:mm:ss");
				} 
			},
			{"data": "isRead"},
			{
				"data": "id",
				"className": "operate-col",
				"render": function(data, type, row, meta){
					var html = '<button type="button" onclick="edit(\''+ data +'\')" class="btn btn-sm btn-warning right-5"><i class="fa fa-edit"></i></button>'
						+ '<button type="button" onclick="view(\''+ data +'\')" class="btn btn-sm btn-info"><i class="fa fa-search"></i></button>';
					return html;
				}
			}
		]
	});
	
	$('#searchBtn').click(function(){
		dataTable.ajax.reload();
	});
	
	$('#resetBtn').click(function(){
		$('#bpUserMessageSearchForm')[0].reset();
		dataTable.ajax.reload();
	});
	
//	$('#addBtn').click(function(){
//		forwardPage('/bpUserMessage/bpUserMessage');
//	});
	
//	$('#delBtn').click(function(){
//		ajaxBySelecteRows(dataTable,'/bpUserMessage/delete','确定要删除？');
//	});
	
	// 日期
	$('.datepicker').datetimepicker({
		language: 'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose: true,
		todayBtn: true,
		clearBtn:true,
		minView: 2
	});
});

//function edit(id){
//	forwardPage('/bpUserMessage/bpUserMessage?id='+id);
//}

function view(id){
	forwardPage('/bpUserMessage/view?id='+id);
}